package com.ruoyi.web.controller.combat.userlocation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.combat.domain.userlocation.CombatLocationTask;
import com.ruoyi.combat.service.userlocation.ICombatLocationTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抗定位任务Controller
 * 
 * @author ruoyi
 * @date 2024-08-30
 */
@Api(tags = "课题三：网络抗定位-抗定位任务管理")
@RestController
@RequestMapping("/userlocation/task")
public class CombatLocationTaskController extends BaseController
{
    @Autowired
    private ICombatLocationTaskService combatLocationTaskService;

    /**
     * 查询抗定位任务列表
     */
    @ApiOperation(value = "查询抗定位任务列表")
    @PreAuthorize("@ss.hasPermi('system:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatLocationTask combatLocationTask)
    {
        startPage();
        List<CombatLocationTask> list = combatLocationTaskService.selectCombatLocationTaskList(combatLocationTask);
        return getDataTable(list);
    }

    /**
     * 导出抗定位任务列表
     */
    @ApiOperation(value = "导出抗定位任务列表")
    @PreAuthorize("@ss.hasPermi('system:task:export')")
    @Log(title = "抗定位任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatLocationTask combatLocationTask)
    {
        List<CombatLocationTask> list = combatLocationTaskService.selectCombatLocationTaskList(combatLocationTask);
        ExcelUtil<CombatLocationTask> util = new ExcelUtil<CombatLocationTask>(CombatLocationTask.class);
        util.exportExcel(response, list, "抗定位任务数据");
    }

    /**
     * 获取抗定位任务详细信息
     */
    @ApiOperation(value = "获取抗定位任务详细信息")
    @PreAuthorize("@ss.hasPermi('system:task:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatLocationTaskService.selectCombatLocationTaskById(id));
    }

    /**
     * 新增抗定位任务
     */
    @ApiOperation(value = "新增抗定位任务")
    @PreAuthorize("@ss.hasPermi('system:task:add')")
    @Log(title = "抗定位任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CombatLocationTask combatLocationTask)
    {
        return toAjax(combatLocationTaskService.insertCombatLocationTask(combatLocationTask));
    }

    /**
     * 修改抗定位任务
     */
    @ApiOperation(value = "修改抗定位任务")
    @PreAuthorize("@ss.hasPermi('system:task:edit')")
    @Log(title = "抗定位任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatLocationTask combatLocationTask)
    {
        return toAjax(combatLocationTaskService.updateCombatLocationTask(combatLocationTask));
    }

    /**
     * 删除抗定位任务
     */
    @ApiOperation(value = "删除抗定位任务")
    @PreAuthorize("@ss.hasPermi('system:task:remove')")
    @Log(title = "抗定位任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatLocationTaskService.deleteCombatLocationTaskByIds(ids));
    }
}
